<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改游戏</title>
    <link rel="stylesheet" href="__ACSS__/table.css">
    <script src="__AJS__/jquery-3.3.1.min.js"></script>
</head>
<body>
    <div class="table-wrap">
        <div class="table-main">
            <div class="ibox-title">
                <h3>编辑游戏</small></h3>
            </div>
            <div class="ibox-content">
                <form action="{:url('admin/game/update', ['id'=>$id])}" class="form-main" method="post" enctype="multipart/form-data">

                    <div class="form-group">
                        <ul>
                            <li>
                                <span class="form-title">游戏分类</span>
                                <select name="cateid" class="form-select">
                                    {volist name="cate" id="vo"}
                                    <option value="{$vo.cid}"
                                            {if condition="($vo.cid eq $cateid)"} selected {/if}}>{$vo.cateName}</option>
                                    {/volist}
                                </select>

                            </li>
                            <li>
                                <span class="form-title">游戏名</span>
                                <input class="form-text form-w50" type="text"  name="gName" value="{$res.gName}">
                            </li>
                            <li>
                                <span class="form-title">游戏描述</span>
                                <input class="form-text form-w50" type="text" name="gDesc" value="{$res.gDesc}">
                            </li>
                            <li>
                                <span class="form-title">预览地址</span>
                                <input class="form-text form-w50" type="text"  name="viewUrl" value="{$res.viewUrl}">
                            </li>
                            <li>
                                <span class="form-title">是否开启</span>
                                <label class="form-radio">
                                    <input type="radio" name="gStatus" value="0" {if condition="($res.gStatus eq 0)"} checked {/if} >开启
                                </label>
                                <label class="form-radio">
                                    <input type="radio" name="gStatus" value="1" {if condition="($res.gStatus eq 1)"} checked {/if} >关闭
                                </label>
                            </li>
                            <li>
                                <span class="form-title">是否最新</span>
                                <label class="form-radio">
                                   <input type="radio" name="isNew" value="0" {if condition="($res.isNew eq 0)"} checked {/if} >最新
                                </label>
                                <label class="form-radio">
                                    <input type="radio" name="isNew" value="1" {if condition="($res.isNew eq 1)"} checked {/if} >非最新
                                </label>
                            </li>
                            <li>
                                <span class="form-title">是否推荐</span>
                                <label class="form-radio">
                                    <input type="radio" name="isRecom" value="0" {if condition="($res.isRecom eq 0)"} checked {/if}>推荐
                                </label>
                                <label class="form-radio">
                                   <input type="radio" name="isRecom" value="1" {if condition="($res.isRecom eq 1)"} checked {/if}>不推荐
                                </label> 
                            </li>
                            <li>
                                <span class="form-title">游戏图片</span>
                                <div class="form-img" title="点击修改图片">
                                    <input type="file" id="fileuploadgame" class="fileupload-input" name="gImg">
                                    <div class="form-img-box">
                                        <div class="form-pre-item">
                                            {if empty($res.gImg)}
                                                <img src="">
                                            {else /}
                                                <img src="/uploads/gameimg/{$res.gImg}">
                                            {/if}
                                        </div>
                                        <em class="edit_img_icon">&nbsp;</em>
                                    </div>
                                </div>
                            </li>

                            <li>
                                <span class="form-title"></span>
                                <input class="form-submit-btn submit-btn" type="submit" value="提交">
                                <a href="{:url('admin/game/index')}" class="form-back-btn"  name="">返回</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <script>
        $(document).ready(function(){
            // 本地化预览图片
            if ( !$('.form-pre-item>img').attr('src') ) {
                $('.form-pre-item').hide();
            }
            // 单个
            $('#fileuploadgame').change(function(){
                var objUrl = getObjectURL(this.files[0]) ;
                if ( objUrl ) {
                    $(this).next('div').find('.form-pre-item').children('img').attr('src',objUrl);
                    $('.form-pre-item').show();
                }
            });
            
        });
        // 本地化预览图片 //建立一個可存取到該file的url
        function getObjectURL(file) {
            var url = null ;
            if (window.createObjectURL!=undefined) { // basic
                url = window.createObjectURL(file) ;
            }else if (window.URL!=undefined) {
            // mozilla(firefox)
                url = window.URL.createObjectURL(file) ;
            } else if (window.webkitURL!=undefined) {
            // webkit or chrome
                url = window.webkitURL.createObjectURL(file) ;
            }
            return url ;
        }
    </script>

</body>
</html>